package com.example.demofdfs.web.websocket;

import java.io.IOException;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//@Component
public class WebSocketSchedule {

	@Scheduled(cron = "* * * * * MON-FRI")
	public void send() {
		send("1", "xxxxxx" + System.currentTimeMillis());
	}
	
	public static void send(String userId, String msg) {
		WebSocketServer webSocketServer = WebSocketServer.getSession(userId);
		try {
			if (webSocketServer != null) {
				webSocketServer.sendMessage(msg);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
